// Optional Properties #
interface SquareConfig {
  color?: string; // 参数可选
  width?: number;
}

function createSquare(config: SquareConfig): {color: string; area: number} {
  let newSquare = {color: "white", area: 100};
  if (config.color) {
      newSquare.color = config.color;
       // Error: Property 'clor' does not exist on type 'SquareConfig'
       newSquare.color = config.clor;
  }
  if (config.width) {
      newSquare.area = config.width * config.width;
  }
  return newSquare;
}

let mySquare = createSquare({color: "black"});

